import java.util.*;


public class Neighbours {

public static void main(String[] args){
    int boundary = getBoundary();
    int[] inputArray = getInputRow(boundary);
    Integer[] distance = new Integer [boundary - 1];
			
    for (int index = 0; index < distance.length; index++){
        distance[index] = Math.abs(inputArray[index] - inputArray[index + 1]);
	  }
    int minDistance = findMinDistance(distance);		
    		            			
    List<Integer> distanceList = new ArrayList<Integer>(boundary - 1);
    distanceList = Arrays.asList(distance);
    int minDistanceIndex = distanceList.indexOf(minDistance);
    printResult(minDistanceIndex);
}

    private static int getBoundary(){
	      System.out.print("How many numbers do you want to enter in an array? ");
	      Scanner input = new Scanner(System.in);
	      int result = input.nextInt();
	      return result;   	
    }

    private static int[] getInputRow(int boundary){
	      Scanner input = new Scanner(System.in);
	      int[] inputArray = new int[boundary];
    	  System.out.println("Enter numbers (using Enter) to fill inputArray[]: ");
    	  for (int index = 0; index < inputArray.length; index++){
	          inputArray[index] = input.nextInt();
	      } 
	      System.out.print("inputArray[]: ");
        System.out.println(Arrays.toString(inputArray));
	      return inputArray;	
    } 	

    private static int findMinDistance(Integer[] distance){
	      int minDistance = distance[0];
        for (int element : distance){
    	      if (element < minDistance){
    	          minDistance = element;
            } 
        } return minDistance;    			
    }

    private static int printResult(int minDistanceIndex){
	      System.out.print("Index of the first number with the smallest distance to" +
		                     " the second one is: ");
    	  System.out.println(minDistanceIndex);
	      return minDistanceIndex;
    }
}